package com.lb.spring;

import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * @author zhangjun
 * @since 2025/04/23
 */
@Component
public class MyBeanPostProcessor implements BeanPostProcessor {
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) {
        if (bean instanceof UserService) {
            System.out.println("🔁 替换 UserService 为代理对象");
            return new UserServiceProxy();
        }
        return bean;
    }
}
